package ucas.pin.web.services;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ucas.pin.web.repositories.CreateRepository;
@Service
public class TreatCreate {
	@Autowired CreateRepository createRepository;
	
	public void create_treat() throws IOException {
		FileInputStream inputStream = new FileInputStream("/home/tcm/Workspace/zyp/NeoData/Treat.txt");  
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));  
        String str = null;  

        while((str = bufferedReader.readLine()) != null)  
        {
            for(String s : str.split("、")) {
            	String[] ss = s.substring(1, s.length()-1).split(",");
            	System.out.println(ss[0]+":"+ss[1]);
            	createRepository.createTreat(ss[0], ss[1]);
            }
        }
        createRepository.delete_same_relation();
        inputStream.close();  
        bufferedReader.close();  
        //
	}
//	public static void main(String[] args) throws IOException {
//		TreatCreate tc = new TreatCreate();
//		tc.create_treat();
//	}
	
}
